/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.web.util;

/**
 *
 * @author sriram
 */
public enum eContentTypes {
    HTML(".html", "text/html; charset=ISO-8859-15"), 
    CSS(".css","text/css; charset=ISO-8859-15"), 
    JAVASCRIPT(".js", "text/javascript; charset=ISO-8859-15"), 
    JPG(".jpg", "image/jpeg"), 
    JPEG(".jpeg", "image/jpeg"), 
    GIF(".gif", "image/gif"), 
    XML(".xml", "text/xml; charset=ISO-8859-15"),
    SSS(".sss", "text/html; charset=utf-8");

    private final String ext;
    private final String str;
    
    eContentTypes(String ext, String string) {
        this.ext = ext;
        this.str = string;
    }
    
    public String toExt() {
        return ext;
    }
 
    public String toType() {
        return str;
    }
    
    public static String getType(String fileName) {
        String result = new String("text/html; charset=utf-8");
        for (eContentTypes opt : eContentTypes.values()) {
            if(fileName.endsWith(opt.toExt())) {
                result = opt.toType();
                break;
            }
        }
        return result;
    }
}
